	.module queue.c
	.area text(rom, con, rel)
	.dbfile D:\01.Projects\JKElectronics\ATMEGA\CoreModule\sw\examples\lib\queue.c
	.dbfunc e q_init_list _q_init_list fV
	.dbstruct 0 8 struct_q_node
	.dbfield 0 prev pS[struct_q_node]
	.dbfield 2 next pS[struct_q_node]
	.dbfield 4 len I
	.dbfield 6 data pV
	.dbend
	.dbstruct 0 8 struct_q_list
	.dbfield 0 first pS[struct_q_node]
	.dbfield 2 last pS[struct_q_node]
	.dbfield 4 curr pS[struct_q_node]
	.dbfield 6 count I
	.dbend
;           list -> R16,R17
	.even
_q_init_list::
	.dbline -1
	.dbline 19
; 
; 
; #include "queue.h"
; 
; 
; /* ------------------------------------------------------------------------
; ** For Win32 Systems, users may want to enable mutual exclusion for the
; ** queue operations, this provides a mutex per queue along with locking
; ** and unlocking primitives.
; ** ------------------------------------------------------------------------ */
; 
; 
; 
; #define q_lock( q ) INTLOCK( )
; #define q_free( q ) INTFREE( )
; 
; 
; void q_init_list(q_list_type* list)
; {
	.dbline 20
; 	list->first = list->last = NULL;
	clr R2
	clr R3
	movw R30,R16
	std z+3,R3
	std z+2,R2
	std z+1,R3
	std z+0,R2
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbsym r list 16 pS[struct_q_list]
	.dbend
	.dbfunc e q_add_tail _q_add_tail fV
;           node -> R18,R19
;           list -> R16,R17
	.even
_q_add_tail::
	.dbline -1
	.dbline 24
; }
; 
; void q_add_tail(q_list_type* list, q_node_type* node)
; {
	.dbline 25
; 	node->next = list->first;
	movw R30,R16
	ldd R2,z+0
	ldd R3,z+1
	movw R30,R18
	std z+3,R3
	std z+2,R2
	.dbline 26
; 	node->prev = NULL;
	clr R2
	clr R3
	std z+1,R3
	std z+0,R2
	.dbline 28
; 
; 	if( list->first )
	movw R30,R16
	ldd R2,z+0
	ldd R3,z+1
	tst R2
	brne X0
	tst R3
	breq L5
X0:
	.dbline 29
; 		list->first->prev = node;
	ldd R26,z+0
	ldd R27,z+1
	st x+,R18
	st x,R19
	xjmp L6
L5:
	.dbline 31
; 	else
; 		list->last = node;
	movw R30,R16
	std z+3,R19
	std z+2,R18
L6:
	.dbline 33
; 
; 	list->first = node;
	movw R30,R16
	std z+1,R19
	std z+0,R18
	.dbline 34
; 	list->count++;
	movw R24,R30
	adiw R24,6
	movw R30,R24
	ldd R24,z+0
	ldd R25,z+1
	adiw R24,1
	std z+1,R25
	std z+0,R24
	.dbline -2
L4:
	.dbline 0 ; func end
	ret
	.dbsym r node 18 pS[struct_q_node]
	.dbsym r list 16 pS[struct_q_list]
	.dbend
	.dbfunc e q_add_head _q_add_head fV
;           node -> R18,R19
;           list -> R16,R17
	.even
_q_add_head::
	.dbline -1
	.dbline 38
; }
; 
; void q_add_head(q_list_type* list, q_node_type* node)
; {
	.dbline 39
; 	node->next = list->first;
	movw R30,R16
	ldd R2,z+0
	ldd R3,z+1
	movw R30,R18
	std z+3,R3
	std z+2,R2
	.dbline 40
; 	node->prev = NULL;
	clr R2
	clr R3
	std z+1,R3
	std z+0,R2
	.dbline 42
; 
; 	if( list->first )
	movw R30,R16
	ldd R2,z+0
	ldd R3,z+1
	tst R2
	brne X1
	tst R3
	breq L8
X1:
	.dbline 43
; 		list->first->prev = node;
	ldd R26,z+0
	ldd R27,z+1
	st x+,R18
	st x,R19
	xjmp L9
L8:
	.dbline 45
; 	else
; 		list->last = node;
	movw R30,R16
	std z+3,R19
	std z+2,R18
L9:
	.dbline 47
; 
; 	list->first = node;
	movw R30,R16
	std z+1,R19
	std z+0,R18
	.dbline 48
; 	list->count++;
	movw R24,R30
	adiw R24,6
	movw R30,R24
	ldd R24,z+0
	ldd R25,z+1
	adiw R24,1
	std z+1,R25
	std z+0,R24
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbsym r node 18 pS[struct_q_node]
	.dbsym r list 16 pS[struct_q_list]
	.dbend
	.dbfunc e q_remove_node _q_remove_node fV
;           node -> R18,R19
;           list -> R16,R17
	.even
_q_remove_node::
	.dbline -1
	.dbline 52
; }
; 
; void q_remove_node(q_list_type* list, q_node_type* node)
; {
	.dbline 53
; 	if( node->next )
	movw R30,R18
	ldd R2,z+2
	ldd R3,z+3
	tst R2
	brne X2
	tst R3
	breq L11
X2:
	.dbline 54
; 		node->next->prev = node->prev;
	ldd R2,z+0
	ldd R3,z+1
	ldd R26,z+2
	ldd R27,z+3
	st x+,R2
	st x,R3
	xjmp L12
L11:
	.dbline 56
; 	else
; 		list->last = node->prev;
	movw R30,R18
	ldd R2,z+0
	ldd R3,z+1
	movw R30,R16
	std z+3,R3
	std z+2,R2
L12:
	.dbline 58
; 
; 	if( node->prev )
	movw R30,R18
	ldd R2,z+0
	ldd R3,z+1
	tst R2
	brne X3
	tst R3
	breq L13
X3:
	.dbline 59
; 		node->prev->next = node->next;
	ldd R2,z+2
	ldd R3,z+3
	ldd R26,z+0
	ldd R27,z+1
	adiw R26,2
	st x+,R2
	st x,R3
	xjmp L14
L13:
	.dbline 61
; 	else
; 		list->first = node->next;
	movw R30,R18
	ldd R2,z+2
	ldd R3,z+3
	movw R30,R16
	std z+1,R3
	std z+0,R2
L14:
	.dbline 63
; 
; 	list->count--;
	movw R24,R16
	adiw R24,6
	movw R30,R24
	ldd R24,z+0
	ldd R25,z+1
	sbiw R24,1
	std z+1,R25
	std z+0,R24
	.dbline -2
L10:
	.dbline 0 ; func end
	ret
	.dbsym r node 18 pS[struct_q_node]
	.dbsym r list 16 pS[struct_q_list]
	.dbend
	.dbfunc e q_remove_head _q_remove_head fpS[struct_q_node]
;           node -> R10,R11
;           list -> R12,R13
	.even
_q_remove_head::
	xcall push_xgset003C
	movw R12,R16
	.dbline -1
	.dbline 67
; }
; 
; q_node_type* q_remove_head(q_list_type* list)
; {
	.dbline 68
; 	q_node_type* node = list->first;
	movw R30,R12
	ldd R10,z+0
	ldd R11,z+1
	.dbline 70
; 
; 	if( !node )
	tst R10
	brne L16
	tst R11
	brne L16
X4:
	.dbline 71
; 		return NULL;
	clr R16
	clr R17
	xjmp L15
L16:
	.dbline 73
; 
; 	q_remove_node(list, node);
	movw R18,R10
	movw R16,R12
	xcall _q_remove_node
	.dbline 74
; 	return node;
	movw R16,R10
	.dbline -2
L15:
	.dbline 0 ; func end
	xjmp pop_xgset003C
	.dbsym r node 10 pS[struct_q_node]
	.dbsym r list 12 pS[struct_q_list]
	.dbend
	.dbfunc e q_remove_tail _q_remove_tail fpS[struct_q_node]
;           node -> R10,R11
;           list -> R20,R21
	.even
_q_remove_tail::
	xcall push_xgset300C
	movw R20,R16
	.dbline -1
	.dbline 78
; }
; 
; q_node_type* q_remove_tail(q_list_type* list)
; {
	.dbline 79
; 	q_node_type* node = list->last;
	movw R30,R20
	ldd R10,z+2
	ldd R11,z+3
	.dbline 81
; 
; 	if( !node )
	tst R10
	brne L19
	tst R11
	brne L19
X5:
	.dbline 82
; 		return NULL;
	clr R16
	clr R17
	xjmp L18
L19:
	.dbline 84
; 
; 	q_remove_node(list, node);
	movw R18,R10
	movw R16,R20
	xcall _q_remove_node
	.dbline 85
; 	return node;
	movw R16,R10
	.dbline -2
L18:
	.dbline 0 ; func end
	xjmp pop_xgset300C
	.dbsym r node 10 pS[struct_q_node]
	.dbsym r list 20 pS[struct_q_list]
	.dbend
	.dbfunc e q_remove_all _q_remove_all fV
;           node -> R12,R13
;           list -> R10,R11
	.even
_q_remove_all::
	xcall push_xgset003C
	movw R10,R16
	.dbline -1
	.dbline 89
; }
; 
; void q_remove_all(q_list_type* list)
; {
L22:
	.dbline 91
; 	q_node_type* node;
; 	while((node = q_remove_head(list)) != NULL );
L23:
	.dbline 91
	movw R16,R10
	xcall _q_remove_head
	movw R12,R16
	tst R12
	brne L22
	tst R13
	brne L22
X6:
	.dbline -2
L21:
	.dbline 0 ; func end
	xjmp pop_xgset003C
	.dbsym r node 12 pS[struct_q_node]
	.dbsym r list 10 pS[struct_q_list]
	.dbend
	.dbfunc e q_get_count _q_get_count fI
;           list -> R16,R17
	.even
_q_get_count::
	.dbline -1
	.dbline 95
; }
; 
; s16 q_get_count(q_list_type* list)
; {
	.dbline 96
; 	return list->count;
	movw R30,R16
	ldd R16,z+6
	ldd R17,z+7
	.dbline -2
L25:
	.dbline 0 ; func end
	ret
	.dbsym r list 16 pS[struct_q_list]
	.dbend
; }
